package com.wind.mvc;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.concurrent.TimeUnit;

/**
 * @author Wind
 */
@Controller
@RequestMapping("/jump")
public class TiaoBanController {

    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    @PostMapping("/data")
    public String data() {

        // 存
        redisTemplate.opsForValue().set("http://open.api.tianyancha.com/services/v4/open/roles?hid=1984012283&name=北京百度网讯科技有限公司&humanName=李彦宏&cid=22822", "{\n" +
                "    \"result\": {\n" +
                "        \"legalList\": [\n" +
                "            {\n" +
                "                \"hid\": 1984012283,\n" +
                "                \"legal_person_type\": 1,\n" +
                "                \"regStatus\": \"存续\",\n" +
                "                \"estiblishTime\": 1300377600000,\n" +
                "                \"regCapital\": \"165000万人民币\",\n" +
                "                \"type\": \"lp\",\n" +
                "                \"legalPersonName\": \"李彦宏\",\n" +
                "                \"legal_person_id\": 161646,\n" +
                "                \"legalPersonPid\": \"ebcf803d8bd2f3071165440b5fbad087231f6415\",\n" +
                "                \"name\": \"福建百度博瑞网络科技有限公司\",\n" +
                "                \"logo\": \"\",\n" +
                "                \"base\": \"fj\",\n" +
                "                \"cid\": 2344179270\n" +
                "            }\n" +
                "        ],\n" +
                "        \"holderList\": [\n" +
                "            {\n" +
                "                \"legal_person_type\": 1,\n" +
                "                \"regStatus\": \"存续\",\n" +
                "                \"estiblishTime\": 1335283200000,\n" +
                "                \"regCapital\": \"1001.000000万人民币\",\n" +
                "                \"type\": \"sh\",\n" +
                "                \"percent\": \"99.9%\",\n" +
                "                \"legalPersonName\": \"周达\",\n" +
                "                \"legal_person_id\": 1984012283,\n" +
                "                \"subscribed\": \"\",\n" +
                "                \"legalPersonPid\": \"bbc3dbafbbf234d4c69cd5c78952f5a0f268bb80\",\n" +
                "                \"name\": \"北京宏景天下投资有限公司\",\n" +
                "                \"logo\": \"https://img5.tianyancha.com/logo/lll/c2cc5941d1b44e1a0a395922adb5a77f.png@!f_200x200\",\n" +
                "                \"base\": \"bj\",\n" +
                "                \"cid\": 28772771\n" +
                "            },\n" +
                "            {\n" +
                "                \"legal_person_type\": 1,\n" +
                "                \"regStatus\": \"存续\",\n" +
                "                \"estiblishTime\": 1516723200000,\n" +
                "                \"regCapital\": \"1000.000000万人民币\",\n" +
                "                \"type\": \"sh\",\n" +
                "                \"percent\": \"90%\",\n" +
                "                \"legalPersonName\": \"吕文颖\",\n" +
                "                \"legal_person_id\": 1984012283,\n" +
                "                \"subscribed\": \"\",\n" +
                "                \"legalPersonPid\": \"02f8953123b66862647b8b4d39cae5ee80eee0af\",\n" +
                "                \"name\": \"北京百众投资管理有限公司\",\n" +
                "                \"logo\": \"\",\n" +
                "                \"base\": \"bj\",\n" +
                "                \"cid\": 3150572380\n" +
                "            },\n" +
                "            {\n" +
                "                \"legal_person_type\": 1,\n" +
                "                \"regStatus\": \"存续\",\n" +
                "                \"estiblishTime\": 991670400000,\n" +
                "                \"regCapital\": \"1342128.000000万人民币\",\n" +
                "                \"type\": \"sh\",\n" +
                "                \"percent\": \"99.5%\",\n" +
                "                \"legalPersonName\": \"梁志祥\",\n" +
                "                \"legal_person_id\": 1984012283,\n" +
                "                \"subscribed\": \"\",\n" +
                "                \"legalPersonPid\": \"87dad05e32c04ae864f562408641a1bcdbba773f\",\n" +
                "                \"name\": \"北京百度网讯科技有限公司\",\n" +
                "                \"logo\": \"https://img5.tianyancha.com/logo/lll/1dfcb74d2e5ecd07a0fb5bb45171983b.png@!f_200x200\",\n" +
                "                \"base\": \"bj\",\n" +
                "                \"cid\": 22822\n" +
                "            },\n" +
                "            {\n" +
                "                \"legal_person_type\": 1,\n" +
                "                \"regStatus\": \"存续\",\n" +
                "                \"estiblishTime\": 1358438400000,\n" +
                "                \"regCapital\": \"923.080000万人民币\",\n" +
                "                \"type\": \"sh\",\n" +
                "                \"percent\": \"99.5%\",\n" +
                "                \"legalPersonName\": \"梁志祥\",\n" +
                "                \"legal_person_id\": 1984012283,\n" +
                "                \"subscribed\": \"\",\n" +
                "                \"legalPersonPid\": \"87dad05e32c04ae864f562408641a1bcdbba773f\",\n" +
                "                \"name\": \"千百糯文化传媒（北京）有限公司\",\n" +
                "                \"logo\": \"\",\n" +
                "                \"base\": \"bj\",\n" +
                "                \"cid\": 3009884272\n" +
                "            },\n" +
                "            {\n" +
                "                \"legal_person_type\": 1,\n" +
                "                \"regStatus\": \"存续\",\n" +
                "                \"estiblishTime\": 1300377600000,\n" +
                "                \"regCapital\": \"165000.000000万人民币\",\n" +
                "                \"type\": \"sh\",\n" +
                "                \"percent\": \"51%\",\n" +
                "                \"legalPersonName\": \"李彦宏\",\n" +
                "                \"legal_person_id\": 1984012283,\n" +
                "                \"subscribed\": \"\",\n" +
                "                \"legalPersonPid\": \"ebcf803d8bd2f3071165440b5fbad087231f6415\",\n" +
                "                \"name\": \"福建百度博瑞网络科技有限公司\",\n" +
                "                \"logo\": \"\",\n" +
                "                \"base\": \"fj\",\n" +
                "                \"cid\": 2344179270\n" +
                "            },\n" +
                "            {\n" +
                "                \"legal_person_type\": 1,\n" +
                "                \"regStatus\": \"存续\",\n" +
                "                \"estiblishTime\": 1598198400000,\n" +
                "                \"regCapital\": \"185.200000万人民币\",\n" +
                "                \"type\": \"sh\",\n" +
                "                \"percent\": \"1%\",\n" +
                "                \"legalPersonName\": \"刘维\",\n" +
                "                \"legal_person_id\": 1984012283,\n" +
                "                \"subscribed\": \"\",\n" +
                "                \"legalPersonPid\": \"49dc34d03482ad160ba1c172f6203abdd3bf781b\",\n" +
                "                \"name\": \"百图生科（北京）智能技术有限公司\",\n" +
                "                \"logo\": \"https://img5.tianyancha.com/logo/lll/704a166fcbcaae6d6222d6553d1c4156.png@!f_200x200\",\n" +
                "                \"base\": \"bj\",\n" +
                "                \"cid\": 3468245142\n" +
                "            }\n" +
                "        ],\n" +
                "        \"officeList\": [\n" +
                "            {\n" +
                "                \"legal_person_id\": 116916,\n" +
                "                \"legalPersonPid\": \"87dad05e32c04ae864f562408641a1bcdbba773f\",\n" +
                "                \"regStatus\": \"存续\",\n" +
                "                \"legal_person_type\": 1,\n" +
                "                \"estiblishTime\": 991670400000,\n" +
                "                \"regCapital\": \"1342128.000000万人民币\",\n" +
                "                \"name\": \"北京百度网讯科技有限公司\",\n" +
                "                \"logo\": \"https://img5.tianyancha.com/logo/lll/1dfcb74d2e5ecd07a0fb5bb45171983b.png@!f_200x200\",\n" +
                "                \"type\": \"执行董事\",\n" +
                "                \"base\": \"bj\",\n" +
                "                \"cid\": 22822,\n" +
                "                \"legalPersonName\": \"梁志祥\"\n" +
                "            },\n" +
                "            {\n" +
                "                \"legal_person_id\": 589528,\n" +
                "                \"legalPersonPid\": \"1c44962b2f3bf9316856c796c514a4222425c503\",\n" +
                "                \"regStatus\": \"开业\",\n" +
                "                \"legal_person_type\": 1,\n" +
                "                \"estiblishTime\": 1326211200000,\n" +
                "                \"regCapital\": \"28600.000000万美元\",\n" +
                "                \"name\": \"百度云计算技术（山西）有限公司\",\n" +
                "                \"logo\": \"\",\n" +
                "                \"type\": \"执行董事\",\n" +
                "                \"base\": \"sx\",\n" +
                "                \"cid\": 799248041,\n" +
                "                \"legalPersonName\": \"崔珊珊\"\n" +
                "            },\n" +
                "            {\n" +
                "                \"legal_person_id\": 161646,\n" +
                "                \"legalPersonPid\": \"ebcf803d8bd2f3071165440b5fbad087231f6415\",\n" +
                "                \"regStatus\": \"存续\",\n" +
                "                \"legal_person_type\": 1,\n" +
                "                \"estiblishTime\": 1300377600000,\n" +
                "                \"regCapital\": \"165000.000000万人民币\",\n" +
                "                \"name\": \"福建百度博瑞网络科技有限公司\",\n" +
                "                \"logo\": \"\",\n" +
                "                \"type\": \"董事长\",\n" +
                "                \"base\": \"fj\",\n" +
                "                \"cid\": 2344179270,\n" +
                "                \"legalPersonName\": \"李彦宏\"\n" +
                "            },\n" +
                "            {\n" +
                "                \"legal_person_id\": 78048,\n" +
                "                \"legalPersonPid\": \"b76468cb2f55374e97e44387fe4f0cea3b733c61\",\n" +
                "                \"regStatus\": \"正常\",\n" +
                "                \"legal_person_type\": 1,\n" +
                "                \"estiblishTime\": 1294329600000,\n" +
                "                \"regCapital\": \"2000.00 （单位：元/万元）\",\n" +
                "                \"name\": \"北京百度公益基金会\",\n" +
                "                \"logo\": \"\",\n" +
                "                \"type\": \"曾任高管\",\n" +
                "                \"base\": \"bj\",\n" +
                "                \"cid\": 3079056799,\n" +
                "                \"legalPersonName\": \"王路\"\n" +
                "            },\n" +
                "            {\n" +
                "                \"legal_person_id\": 116916,\n" +
                "                \"legalPersonPid\": \"87dad05e32c04ae864f562408641a1bcdbba773f\",\n" +
                "                \"regStatus\": \"存续\",\n" +
                "                \"legal_person_type\": 1,\n" +
                "                \"estiblishTime\": 1204041600000,\n" +
                "                \"regCapital\": \"400000.000000万人民币\",\n" +
                "                \"name\": \"北京度小满支付科技有限公司\",\n" +
                "                \"logo\": \"https://img5.tianyancha.com/logo/lll/8804acde415a632bfa16b411a0358b8a.png@!f_200x200\",\n" +
                "                \"type\": \"监事\",\n" +
                "                \"base\": \"bj\",\n" +
                "                \"cid\": 3381591494,\n" +
                "                \"legalPersonName\": \"梁志祥\"\n" +
                "            }\n" +
                "        ]\n" +
                "    },\n" +
                "    \"reason\": \"ok\",\n" +
                "    \"error_code\": 0\n" +
                "}");

        // 设置过期时间
        redisTemplate.expire("http://open.api.tianyancha.com/services/v4/open/roles?hid=1984012283&name=北京百度网讯科技有限公司&humanName=李彦宏&cid=22822", 10L, TimeUnit.SECONDS);

        // 取
        String value = redisTemplate.opsForValue().get("http://open.api.tianyancha.com/services/v4/open/roles?hid=1984012283&name=北京百度网讯科技有限公司&humanName=李彦宏&cid=22822");
        System.out.println(value);
        return "redirect:https://www.baidu.com/";
    }
}
